package com.XiGuaXiaoMe.controller.stu;

import com.XiGuaXiaoMe.dao.userDao;
import com.XiGuaXiaoMe.entity.Users;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class userDeleteServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       String userId;
       userDao dao=new userDao();
       int result=0;
       PrintWriter out=null;
        //1.【调用请求对象】读取【请求头】参数信息
        userId=req.getParameter("userId");
        //2.【调用DAO】将用户编号填充到delete命令并发送到数据库服务器
        result=dao.delete(userId);
        //3.【调用响应对象】将处理结果以二进制写入到响应体，交给浏览器
        resp.setContentType("text/html;charset=utf-8");
        out= resp.getWriter();
        if(result==1)
        {
           out.print("<font>删除成功</font>");
        }else{
            out.print("<font>删除失败</font>");
        }
    }
}
